<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "{{%apply}}".
 *
 * @property integer $user_id
 * @property integer $apply_id
 * @property integer $job_id
 * @property integer $apply_status
 *
 * @property Job $apply
 * @property User $user
 */
class ApplyModel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%apply}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'job_id', 'apply_status'], 'required'],
            [['user_id', 'job_id', 'apply_status'], 'integer'],
            [['apply_id'], 'exist', 'skipOnError' => true, 'targetClass' => Job::className(), 'targetAttribute' => ['apply_id' => 'job_id']],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'user_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'user_id' => Yii::t('app', 'User ID'),
            'apply_id' => Yii::t('app', 'Apply ID'),
            'job_id' => Yii::t('app', 'Job ID'),
            'apply_status' => Yii::t('app', 'Apply Status'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getApply()
    {
        return $this->hasOne(Job::className(), ['job_id' => 'apply_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['user_id' => 'user_id']);
    }
}
